/*
    Copyright 2010 Barnet Wagman

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
 */

package com.norbl.util;

import java.lang.reflect.*;

/** Used to create ordered lists of fields in a
 *  {@link DbEl}.<p>
 *
 *  Implementation note:  in principle this could be accomplished
 *  more elegantly using enums and reflection.  But using
 *  <tt>DbElField</tt> ends up being much more concise.
 *
 * @author Barnet Wagman
 */
public class DbElField {

    public Object val;
    public String name;
    public String displayName;
    public Field field;

    public DbElField(Field field, Object val,String displayName) {
        this.val = val;
        this.name = field.getName();
        this.displayName = displayName;
        this.field = field;
    }

        /** Just returns the <tt>val</tt> but can
         *  overwritten to specify the display format.
         * 
         * @return value
         */
    public Object getDisplayValue() {
        return(val);
    }

    public String toString() {
        return( name + " " + displayName + " " + getDisplayValue());
    }

        /** Overwrite for value conversion.
         *
         * @return value
         */
    public Object getVal() { return(val); }
}
